package com.zyy.api.converter;

import com.alibaba.fastjson.JSON;
import com.zyy.api.pojo.LabelRule;

import javax.persistence.AttributeConverter;
import javax.persistence.Converter;

/**
 *@author zhangyangyang
 *@createTime 2023414 15:59
 *@description 标签规则转换器
 */
@Converter
public class LabelRuleConverter implements AttributeConverter<LabelRule, String> {
    @Override public String convertToDatabaseColumn(LabelRule labelRule) {
        return JSON.toJSONString(labelRule);
    }

    @Override public LabelRule convertToEntityAttribute(String s) {
        return JSON.parseObject(s, LabelRule.class);
    }
}
